package com.lightswitch.smarttranslator.webservice;

import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;

/**
 * 
 * @author HieuPham
 */
public class ServiceInstance {
    public static void start() {
        new Thread() {
            @Override
            public void run() {
                
                try {
                    SmartTranslatorService.Processor processor = new SmartTranslatorService.Processor(new ServiceProcessor());
                    TServerTransport serverTransport = new TServerSocket(9090);
                    TThreadPoolServer.Args config = new TThreadPoolServer.Args(serverTransport);
                    config.maxWorkerThreads = 25;
                    config.minWorkerThreads = 2;
                    config.processor(processor);
                    TServer server = new TThreadPoolServer(config);
                    server.serve();
                } catch (TTransportException ex) {
                    System.out.println(ex);
                }
            }
        }.start();
    }
}